#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time   : 2023-09-24 15:09
# @Author : hard work
# @File    : pyshark_util.py
# @Description :
import sys
import time


def progress_bar(info1):
    print("%s" % info1)
    for i in range(1, 101):
        print("\r", end="")
        print("当前进度为: {}%: ".format(i), "▋" * (i // 2), end="")
        sys.stdout.flush()
        time.sleep(0.001)


def addr2dec(addr):
    "将点分十进制IP地址转换成十进制整数"
    items = [int(x) for x in addr.split(".")]
    return sum([items[i] << [24, 16, 8, 0][i] for i in range(4)])


def dec2addr(dec):
    "将十进制整数IP转换成点分十进制的字符串IP地址"
    return ".".join([str(dec >> x & 0xff) for x in [24, 16, 8, 0]])
